package utils.js;

public class jQueryUIPlugins {
	
	 public static String getHTMLScriptCalendario(String nombreComponente, String path){
		 String html = "";
		 html += "<script type=\"text/javascript\">";
		 html += "$(function() {";                                                                                                                                                                
		 html += "          $(\"#"+nombreComponente+"\").datepicker({showOn: 'button', buttonImage: '"+path+"jquery-ui/development-bundle/demos/datepicker/images/calendar.gif', buttonImageOnly: true});";
		 html += "});";
		 html += "</script>";	 
		 return html;
	 }
	 
	 public static String getHTMLScriptTime(String nombreComponente){
		 String html = "";
		 html += "<script type=\"text/javascript\">\n";
		  html += "$(function() {";
		  html += "          $(\"#"+nombreComponente+"\").timePicker({\n";
		  html += "	                startTime: \"06.00\", \n";// Using string. Can take string or Date object.
		  html += "		            endTime: new Date(0, 0, 0, 15, 30, 0), \n";// Using Date object here.
		  html += "		            show24Hours: false,\n";
		  html += "		            separator: ':',\n";
		  html += "		            step: 30});\n";
		  html += "});";
		  html += "</script>\n";
		 return html;
	 }
	 
	 public static String getHTMLScriptToggle(String nombreComponente){
		 String html = "";
		 html += "<script type=\"text/javascript\">\n";
		 html += "$(document).ready(function() {\n";
		 html += "$('#"+nombreComponente+"').toggle(function() {\n";
		 html += "$('#"+nombreComponente+"').slideToggle(\"slow\");\n";
		 html += "});\n";
		 html += "});\n";
		 html += "</script>\n";
		 return html;
	 }
	 
	 public static String getHTMLScriptTimeDual(String nombreComponente1, String nombreComponente2){
		 String html = "";
	 
		 html += "<script type=\"text/javascript\">\n";
		 html += "$(function() {\n";
	     /*// Default.
		 html += "$(\"#time1\").timePicker();\n";
	     // 02.00 AM - 03.30 PM, 15 minutes steps.
		 html += "$(\"#time2\").timePicker({\n";
		 html += " startTime: \"02.00\",\n";  // Using string. Can take string or Date object.
		 html += "endTime: new Date(0, 0, 0, 15, 30, 0),\n";  // Using Date object here.
		 html += "show24Hours: false,\n";
		 html += "separator:'.',\n";
		 html += "step: 15});\n";*/
	    
	    // An example how the two helper functions can be used to achieve 
	    // advanced functionality.
	    // - Linking: When changing the first input the second input is updated and the
	    //   duration is kept.
	    // - Validation: If the second input has a time earlier than the firs input,
	    //   an error class is added.
	    
	    // Use default settings
		html += "$(\"#"+nombreComponente1+", #"+nombreComponente2+"\").timePicker({startTime: \"06:00\",endTime: new Date(0, 0, 0, 20, 30, 0),show24Hours: true,separator:':',step: 30});\n";
	        
	    // Store time used by duration.
		html += "var oldTime = $.timePicker(\"#"+nombreComponente1+"\").getTime();\n";
	    
	    // Keep the duration between the two inputs.
		html += "$(\"#"+nombreComponente1+"\").change(function() {\n";
		html += "     if ($(\"#"+nombreComponente2+"\").val()) {\n"; // Only update when second input has a value.
	    // Calculate duration.
		html += "           var duration = ($.timePicker(\"#"+nombreComponente2+"\").getTime() - oldTime);\n";
		html += "           var time = $.timePicker(\"#"+nombreComponente1+"\").getTime();\n";
	    // Calculate and update the time in the second input.
		html += "           $.timePicker(\"#"+nombreComponente2+"\").setTime(new Date(new Date(time.getTime() + duration)));\n";
		html += "           oldTime = time;\n";
		html += "     }\n";
		html += "});\n";
	    // Validate.
		html += "$(\"#"+nombreComponente2+"\").change(function() {\n";
		html += "           if($.timePicker(\"#"+nombreComponente1+"\").getTime() > $.timePicker(this).getTime()) {\n";
		html += "                   $(this).addClass(\"error\");\n";
		html += "                   alert('El horario de subida debe ser mayor que el de bajada');\n";
		html += "           }else {\n";
		html += "                   $(this).removeClass(\"error\");\n";
		html += "           }\n";
		html += "});\n";
	    html += "});\n";
		html += "</script>\n";
		return html;
	 }
	 
	 public static String getHTMLScriptCalendarioConEvento(String nombreComponente, String path){
		 String html = "";
		 html += "<script type=\"text/javascript\">";
		 html += "$(function() {";                                                                                                                                                                
		 html += "          $(\"#"+nombreComponente+"\").datepicker({showOn: 'button', buttonImage: '"+path+"jquery-ui/development-bundle/demos/datepicker/images/calendar.gif', buttonImageOnly: true, onClose: antes(form.inicio.value, form.fin.value)});";
		 html += "});";
		 html += "</script>";	 
		 return html;
	 }
	 
	//Asi lo llamariamos....html += utils.js.jQueryUIPlugins.getHTMLScriptTablaPaginada("example");
	 public static String getHTMLScriptTablaPaginada(String idComponente){
		 String html = "";
		 
		 html += "<script type=\"text/javascript\" charset=\"utf-8\">";

		 html += "$(document).ready(function() {";
		 html += "	$('#"+idComponente+"').dataTable( {";
		 html += "	\"sPaginationType\": \"full_numbers\"";
		 html += "		} );";
		 html += "	} );";

		 html += "</script>";	 
		 return html;
	 }
  
	 /*Una vez definido getHTMLScriptTablaPaginada, generamos la tabla de esta forma: 
	 html += utils.Pruebas.getTabla();*/
 public static String getTabla(){
	 String html = "";
	 html += "<div id=\"dt_example\" class=\"example_alt_pagination\">";
	 html += "<div id=\"container\" >";
	 html += "<div id=\"demo\" >";
	 
	 html += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"" +
	 		" class=\"displayTabla\" id=\"example\">";
	
	 html += "	<thead>";
	 html += "<tr>";
	 html += "<th>Rendering engine</th>";
	 html += "<th>Browser</th>";
	 html += "<th>Platform(s)</th>";
	 html += "<th>Engine version</th>";
	 html += "<th>CSS grade</th>";
	 html += "</tr>";
	 html += "</thead>";
	 
	 html += "<tbody>"; 
	 
	 html += "<tr class=\"gradeX\">";
	 html += " <td>Trident</td>";
	 html += " <td> Internet Explorer 4.0 </td>";
	 html += " <td>Win 95+</td>";
	 html += "<td class=\"center\">4</td>";
	 html += "<td class=\"center\">X</td>";
	 html += "</tr>";
	 
	 html += "<tr class=\"gradeC\">";
	 html += "<td>Gecko</td>";
	 html += "<td>Internet Explorer 5.0</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5</td>";
	 html += " <td class=\"center\">C</td>";
	 html += " </tr>";
	 
	 html += " <tr class=\"gradeA\">";
	 html += " <td>WebInt</td>";
	 html += " <td>Konqureror 3.1</td>";
	 html += " <td>KDE 3.1</td>";
	 html += " <td class=\"center\">5.5</td>";
	 html += " <td class=\"center\">A</td>";
	 html += " </tr>";
	 
	 html += "<tr class=\"gradeX\">";
	 html += " <td>Trident</td>";
	 html += " <td> Mozilla</td>";
	 html += " <td>Win 95+</td>";
	 html += "<td class=\"center\">4</td>";
	 html += "<td class=\"center\">X</td>";
	 html += "</tr>";
	 
	 html += "<tr class=\"gradeC\">";
	 html += "<td>Trident</td>";
	 html += "<td>Internet Explorer 5.0</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5</td>";
	 html += " <td class=\"center\">C</td>";
	 html += " </tr>";
	 
	 html += " <tr class=\"gradeA\">";
	 html += " <td>Trident</td>";
	 html += " <td>Internet Explorer 5.5</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5.5</td>";
	 html += " <td class=\"center\">A</td>";
	 html += " </tr>";
	 
	 html += "<tr class=\"gradeX\">";
	 html += " <td>Trident</td>";
	 html += " <td> Internet Explorer 4.0 </td>";
	 html += " <td>Win 95+</td>";
	 html += "<td class=\"center\">4</td>";
	 html += "<td class=\"center\">X</td>";
	 html += "</tr>";
	 
	 html += "<tr class=\"gradeC\">";
	 html += "<td>Trident</td>";
	 html += "<td>Internet Explorer 5.0</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5</td>";
	 html += " <td class=\"center\">C</td>";
	 html += " </tr>";
	 
	 html += " <tr class=\"gradeA\">";
	 html += " <td>Trident</td>";
	 html += " <td>Internet Explorer 5.5</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5.5</td>";
	 html += " <td class=\"center\">A</td>";
	 html += " </tr>";
	 
	 html += "<tr class=\"gradeX\">";
	 html += " <td>Trident</td>";
	 html += " <td> Internet Explorer 4.0 </td>";
	 html += " <td>Win 95+</td>";
	 html += "<td class=\"center\">4</td>";
	 html += "<td class=\"center\">X</td>";
	 html += "</tr>";
	 
	 html += "<tr class=\"gradeC\">";
	 html += "<td>Trident</td>";
	 html += "<td>Internet Explorer 5.0</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5</td>";
	 html += " <td class=\"center\">C</td>";
	 html += " </tr>";
	 
	 html += " <tr class=\"gradeA\">";
	 html += " <td>Trident</td>";
	 html += " <td>Internet Explorer 5.5</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5.5</td>";
	 html += " <td class=\"center\">A</td>";
	 html += " </tr>";
	 
	 html += "<tr class=\"gradeX\">";
	 html += " <td>Trident</td>";
	 html += " <td> Internet Explorer 4.0 </td>";
	 html += " <td>Win 95+</td>";
	 html += "<td class=\"center\">4</td>";
	 html += "<td class=\"center\">X</td>";
	 html += "</tr>";
	 
	 html += "<tr class=\"gradeC\">";
	 html += "<td>Trident</td>";
	 html += "<td>Internet Explorer 5.0</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5</td>";
	 html += " <td class=\"center\">C</td>";
	 html += " </tr>";
	 
	 html += " <tr class=\"gradeA\">";
	 html += " <td>Trident</td>";
	 html += " <td>Internet Explorer 5.5</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5.5</td>";
	 html += " <td class=\"center\">A</td>";
	 html += " </tr>";
	 
	 html += "<tr class=\"gradeX\">";
	 html += " <td>Trident</td>";
	 html += " <td> Internet Explorer 4.0 </td>";
	 html += " <td>Win 95+</td>";
	 html += "<td class=\"center\">4</td>";
	 html += "<td class=\"center\">X</td>";
	 html += "</tr>";
	 
	 html += "<tr class=\"gradeC\">";
	 html += "<td>Trident</td>";
	 html += "<td>Internet Explorer 5.0</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5</td>";
	 html += " <td class=\"center\">C</td>";
	 html += " </tr>";
	 
	 html += " <tr class=\"gradeA\">";
	 html += " <td>Trident</td>";
	 html += " <td>Internet Explorer 5.5</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5.5</td>";
	 html += " <td class=\"center\">A</td>";
	 html += " </tr>";
	 
	 html += "<tr class=\"gradeX\">";
	 html += " <td>Trident</td>";
	 html += " <td> Internet Explorer 4.0 </td>";
	 html += " <td>Win 95+</td>";
	 html += "<td class=\"center\">4</td>";
	 html += "<td class=\"center\">X</td>";
	 html += "</tr>";
	 
	 html += "<tr class=\"gradeC\">";
	 html += "<td>Trident</td>";
	 html += "<td>Internet Explorer 5.0</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5</td>";
	 html += " <td class=\"center\">C</td>";
	 html += " </tr>";
	 
	 html += " <tr class=\"gradeA\">";
	 html += " <td>Trident</td>";
	 html += " <td>Internet Explorer 5.5</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5.5</td>";
	 html += " <td class=\"center\">A</td>";
	 html += " </tr>";
	 
	 html += "<tr class=\"gradeX\">";
	 html += " <td>Trident</td>";
	 html += " <td> Internet Explorer 4.0 </td>";
	 html += " <td>Win 95+</td>";
	 html += "<td class=\"center\">4</td>";
	 html += "<td class=\"center\">X</td>";
	 html += "</tr>";
	 
	 html += "<tr class=\"gradeC\">";
	 html += "<td>Trident</td>";
	 html += "<td>Internet Explorer 5.0</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5</td>";
	 html += " <td class=\"center\">C</td>";
	 html += " </tr>";
	 
	 html += " <tr class=\"gradeA\">";
	 html += " <td>Trident</td>";
	 html += " <td>Internet Explorer 5.5</td>";
	 html += " <td>Win 95+</td>";
	 html += " <td class=\"center\">5.5</td>";
	 html += " <td class=\"center\">A</td>";
	 html += " </tr>";

	 html += " </tbody>";
	 
	 html += " <tfoot>";
	 html += " <tr>";
	 html += " <th>Rendering engine</th>";
	 html += " <th>Browser</th>";
	 html += " <th>Platform(s)</th>";
	 html += " <th>Engine version</th>";
	 html += " <th>CSS grade</th>";
	 html += " </tr>";
	 html += " </tfoot>";
	 
	 
	 html += "	 </table>";
	 html += "</div>"; 
	 html += "</div>";
	 html += "</div>";
	
	 return html;
 }

  public static void main(String args[]) {
	       
      String facultad = "Economicas-1547";
      int idx = facultad.indexOf( '-' );
      String key = facultad.substring( 0, idx );
      String value = facultad.substring( idx+1 );
      
      System.out.println(facultad);
      System.out.println(key);
      System.out.println(value);
      System.out.println(key +" - "+value);
   }
}